package com.eastfair.builder.service.impl;

import com.eastfair.builder.service.BuilderBondConfigService;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.venuebooking.api.BondConfigFeign;
import com.eastfair.venueservice.entity.BondConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 *  保证金配置 service.
 *
 * @author dqq
 * @date 2023 /4/17
 */
@Service
@Slf4j
public class BuilderBondConfigServiceImpl implements BuilderBondConfigService {

    @Resource
    private BondConfigFeign bondConfigFeign;

    @Override
    public BondConfig getBySiteArea(Long exhibitionManageId, Long homeId, BigDecimal siteArea) {
        log.info("getBySiteArea - 展会ID，主场ID，面积查询保证金配置, exhibitionId={}, homeId={}, area={}", exhibitionManageId, homeId, siteArea);
        R<BondConfig> result = bondConfigFeign.getBySiteArea(exhibitionManageId, homeId, siteArea);
        log.info("getBySiteArea - 展会ID，主场ID，面积查询保证金配置, result={}", result);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }
}